/*
 * @Author: your name
 * @Date: 2020-10-08 17:08:27
 * @LastEditTime: 2021-03-16 11:54:04
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \solaxcloud\src\main.js
 */
import "core-js/stable";
import "regenerator-runtime/runtime";
import Vue from 'vue'
// import 'babel-polyfill' //babel 7.4 后弃用 用core-js
import i18n from './lan'
import App from './App'
import router from './router'
import store from './store'
import API from './api/content.js'
// import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
// import 'element-ui/lib/theme-chalk/index.css'
import './assets/style/theme/index.css'
import axios from 'axios'
import promise from 'es6-promise'
import { VueJsonp } from 'vue-jsonp' //调用地图需使用
import Echarts from 'echarts'
import AFTableColumn from 'af-table-column'
require('es6-promise').polyfill()
promise.polyfill() // 兼容 Promise


import { Container, Header, Aside, Main, Footer, Button, Select, Table, TableColumn, Menu, Submenu, MenuItem, Dropdown, DropdownMenu, DropdownItem, Form, FormItem, Input, Checkbox, Message, MessageBox, Alert, Breadcrumb, BreadcrumbItem, Pagination, Dialog, Option, Loading, Row, Col, ButtonGroup, Tabs, TabPane, Popconfirm, Tooltip, Drawer, Popover, Link, Tree, Cascader, DatePicker, TimePicker, Radio, RadioGroup, Notification, Upload, Divider, Switch, TimeSelect, InputNumber, Card, RadioButton, CheckboxGroup } from 'element-ui';


Vue.prototype.echarts = Echarts
Vue.use(VueJsonp)

Vue.use(Echarts)
    // Vue.use(ElementUI)
Vue.use(Container)
Vue.use(CheckboxGroup)
Vue.use(Header)
Vue.use(Aside)
Vue.use(Main)
Vue.use(Footer)
Vue.use(Button)
Vue.use(Select)
Vue.use(Option)
Vue.use(Table)
Vue.use(TableColumn)
Vue.use(Menu)
Vue.use(Submenu)
Vue.use(MenuItem)
Vue.use(Dropdown)
Vue.use(DropdownMenu)
Vue.use(DropdownItem)
Vue.use(Form)
Vue.use(FormItem)
Vue.use(Input)
Vue.use(Checkbox)
Vue.use(Alert)
Vue.use(Pagination)
Vue.use(Breadcrumb)
Vue.use(BreadcrumbItem)
Vue.use(Pagination)
Vue.use(Loading)
Vue.use(Row)
Vue.use(Col)
Vue.use(ButtonGroup)
Vue.use(Tabs)
Vue.use(Dialog)
Vue.use(TabPane)
Vue.use(Popconfirm)
Vue.use(Tooltip)
Vue.use(Drawer)
Vue.use(Popover)
Vue.use(Link)
Vue.use(Tree)
Vue.use(TimePicker)
Vue.use(DatePicker)
Vue.use(Cascader)
Vue.use(Radio)
Vue.use(RadioGroup)
Vue.use(Upload)
Vue.use(Divider)
Vue.use(Switch)
Vue.use(TimeSelect)
Vue.use(InputNumber)
Vue.use(Card)
Vue.use(RadioButton)
Vue.use(AFTableColumn)
Vue.component(Notification)




import './assets/css/common.less'
// import './assets/css/skin.less'
import * as filters from './filters'
import UtilsFun from './utils/common.js'
import comm from './service/comm'
// import * as VueGoogleMaps from 'vue2-google-maps'



// Vue.prototype.$ELEMENT = { size: 'mini', zIndex: 3000 };
Vue.prototype.$ELEMENT = { size: 'small', zIndex: 3000 };

Vue.prototype.comm = comm
Vue.prototype.axios = axios
Vue.config.productionTip = false
Vue.prototype.API = API
    // Vue.prototype.$message = ElementUI.Message;
    // Vue.prototype.$msgbox = ElementUI.MessageBox;
    // Vue.prototype.$alert = ElementUI.MessageBox.alert;
    // Vue.prototype.$confirm = ElementUI.MessageBox.confirm;
    // Vue.prototype.$prompt = ElementUI.MessageBox.prompt;
    // Vue.prototype.$notify = ElementUI.Notification;
Vue.prototype.$message = Message;
Vue.prototype.$msgbox = MessageBox;
Vue.prototype.$alert = MessageBox.alert;
Vue.prototype.$confirm = MessageBox.confirm;
Vue.prototype.$prompt = MessageBox.prompt;
Vue.prototype.$notify = Notification;
Vue.prototype.UtilsFun = UtilsFun;
Vue.prototype.Regs = {
    address: /^[\u4E00-\u9FA5A-Za-z0-9,，#&（）()\s-]+$/, //地址
    email_reg: /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,6})$/, //国际邮箱
    //phone_reg:/^[\d|\-|\+][\d|\-|\+|\*|\s]{0,31}$/,//原国际电话
    phone_reg: /^[\d|\-|\+|\s|\#]+$/, //国际电话
    china_reg: /[\u4e00-\u9fa5]/, //中文
    space_reg: /\s/, //不允许出现空格
    loginName_reg: /^[A-Za-z0-9@._]+$/, //登录账号（只允许出现英文、数字、“@”、“_”、“.”）,
    num_reg: /^\d+(\.\d+)?$/
};
Vue.prototype.baiduMapKey = 'inh0qPVz4a09PXGUYpe0SgCr2GDUiEEh'
Vue.prototype.googleMapKey = 'AIzaSyAjUe8uhN3nlkIc1cC50hCmTo_wab6r63g'

Object.keys(filters).forEach(key => {
    Vue.filter(key, filters[key])
})

Vue.directive('copy', {
    inserted(el, binding) {
        el.setAttribute("style", "cursor:pointer;color:orange;");
        el.addEventListener('click', function(e) {
            var parent = document.querySelector('body');
            let input = document.createElement("input");
            input.setAttribute("id", "copy_text");
            input.setAttribute("type", "text");
            parent.appendChild(input);
            input.value = binding.value
            input.focus();
            input.select();
            document.execCommand('Copy', false, null);
            parent.removeChild(input)
            Vue.prototype.$message({
                message: i18n.t('API.copys') || '复制成功',
                type: 'success'
            })
        })
    }
})
Vue.directive('big', {
    inserted(el, binding) {
        el.querySelector('input').addEventListener('blur', function(e) {
            let value = el.querySelector('input').value.toUpperCase()
            el.querySelector('input').value = value
            el.querySelector('input').dispatchEvent(new Event("input"));
        })
    }
})

// Vue.use(VueGoogleMaps, {
//     load: {
//       key: 'AIzaSyAjUe8uhN3nlkIc1cC50hCmTo_wab6r63g',
//       libraries: 'places',
//       region: 'VI', // 这个地区自己定
//       language: 'en' // 这个语言自己定
//     },
//     installComponents: true
// })

new Vue({
    router,
    i18n,
    store,
    render: h => h(App)
}).$mount('#app')